#ifndef MYCHARTVIEWVV_H
#define MYCHARTVIEWVV_H

#include <QChartView>
#include <QMouseEvent>
#include <QGraphicsSimpleTextItem>

#if (QT_VERSION <= QT_VERSION_CHECK(6,0,0))
QT_CHARTS_USE_NAMESPACE
#endif

    class MyChartViewVV : public QChartView
{
    Q_OBJECT

    using AxisRange = std::array<qreal, 2>;

public:
    explicit MyChartViewVV(QWidget* parent = nullptr);
    MyChartViewVV(QChart *chart, QWidget *parent = nullptr);
    ~MyChartViewVV();
    // Save the coordinate area for resetting
    void saveAxisRange();

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void wheelEvent(QWheelEvent *event);
    void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);

private:
    QPoint m_prevPoint;
    bool m_leftButtonPressed;
    bool m_ctrlPressed;
    bool m_alreadySaveRange;
    AxisRange m_xRange;
    AxisRange m_yRange;
    QGraphicsSimpleTextItem* m_coordItem;

};

#endif // MYCHARTVIEWVV_H
